package com.chushouya.order.constants;


import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

/**
 * 订单分表
 * 100001-300000
 * 300001-500000
 * 500001-700000
 */
public enum OrderLogSubmeterEnum implements IEnum<Long> {

    ONE(100001L, 300000L),
    TWO(300001L, 500000L);
    private Long min;

    private Long max;
    OrderLogSubmeterEnum(Long min, Long max) {
        this.min = min;
        this.max = max;
    }

    public static String getTableName(Long value) {
        String TABLE_NAME = "o_order_log";
        for (OrderLogSubmeterEnum thisEnum : OrderLogSubmeterEnum.values()) {
            if (value >= thisEnum.min && value <= thisEnum.max) {
                return Strings.format("{}_{}_{}", TABLE_NAME, thisEnum.min, thisEnum.max);
            }
        }
        return TABLE_NAME;
    }


    @Override
    public Long value() {
        return max;
    }

    @Override
    public String named() {
        return Strings.EMPTY;
    }
}
